package com.myorg.bionline.gui.control;

import java.net.URI;

import com.myorg.bionline.driver.WebSocketClient;
import com.myorg.domain.BlockInfo;
import com.myorg.domain.SearchRequest;

public class MyRunnable implements Runnable {
	private final BlockInfo blkInfo;
	private final String selectedHost;
	private final SearchRequest request;

	public MyRunnable(String selectedHost, BlockInfo blkInfo, SearchRequest request) {
		this.blkInfo = blkInfo;
		this.selectedHost = selectedHost;
		this.request = request;

	}

	public void run() {
		WebSocketClient wsClient = new WebSocketClient(URI.create("ws://" + selectedHost + ":8080" + "/worker/"));
		wsClient.send("hi websocket server, I am here!");
		wsClient.send("start=" + blkInfo.getBlockLocation().getOffset() + "&end="
				+ (blkInfo.getBlockLocation().getLength() + blkInfo.getBlockLocation().getOffset() - 1) + "&max="
				+ request.getMax() + "&compress=" + (blkInfo.isFileCompressed() ? "Y" : "N") + "&source="
				+ blkInfo.getFilePath() + "&key=" + request.getKey());

	}

}
